package com.borened.common.core.base.result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 分页  响应数据对象
 *
 * @author: cch
 * @since: 2021/11/16
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel("分页结果")
public class PageResult<E> {

    @ApiModelProperty("数据分页记录")
    private List<E> records;
    @ApiModelProperty("数据总条数")
    private Long total;

    public PageResult(IPage<E> page) {
        this.records = page.getRecords();
        this.total = page.getTotal();
    }
}
